package cn.lyvust.shili06;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Description:
 * date: 2021-4-21 13:49
 *
 * @author Guo_guo
 * @since JDK 1.8
 */
public class Test06 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("请输入被除数:");
        try {
            int num1 = in.nextInt();
            System.out.print("请输入除数:");
            int num2 = in.nextInt();
            System.out.println(num1+"/"+ num2 +"="+ num1/ num2);
        } catch (InputMismatchException e) {
            System.err.println("被除数和除数必须是整数。");
        } catch (ArithmeticException e) {
            System.err.println("除数不能为零。");
        } catch (Exception e) {  //该异常捕捉在前，报错
            System.err.println("其他未知异常。");
        } finally {
            System.out.println("感谢使用本程序!");
        }
    }
}
